<?php
include_once('./lib/FreeFunctions.php');

class primeAjax
{
    private $mQuery;
    private $common;
    
    public function __construct()
    {
        $this -> mQuery = new mainQuery();
        $this -> common = new CommonQuery();        
    }

    public function searchInOffers()
    {          
        $phrase = $_POST['phrase'];  
        $searchPhrase = $this -> mQuery -> searchLastOffers($phrase);
        
        $response = '';
        
        foreach($searchPhrase as $key => $value)
        {
            $response .= '<li class="s1">
                                <h2>
                                    <a>'.$value['who_work'].'</a>
                                </h2>
                                <p>
                                    '.$value['description'].' 
                                </p>
                                <a class="see">ważna do: '.$value['end_date'].'</a>
                            </li>';    
        }
        
        echo json_encode($response);exit;        
    }
}
?>
